import { namespace, connent, elementConnent } from '../config'

export function useUamespace(block: string) {
  // block
  const b = () => _bem({ block })
  // element
  const e = (element: string) => (element ? _bem({ element, block }) : '')

  return {
    b,
    e,
  }
}

const _bem = (params: { block: string; element?: string }) => {
  let className = `${namespace}${connent}${params.block}`

  params.element && (className += `${elementConnent}${params.element}`)

  return className
}
